package edu.cs.usask.ca.silver.plugin.rcp.intro;

import java.io.PrintWriter;
import java.util.Date;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.intro.config.IIntroContentProviderSite;
import org.eclipse.ui.intro.config.IIntroXHTMLContentProvider;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class DynamicContentProvider implements IIntroXHTMLContentProvider {

	public void init(IIntroContentProviderSite site) {
	}

	public void createContent(String id, PrintWriter out) {
	}

	public void createContent(String id, Composite parent, FormToolkit toolkit) {
	}

	private String getCurrentTimeString() {
		StringBuffer content = new StringBuffer(
				"Dynamic content from Intro ContentProvider: ");
		content.append("Current time is: ");
		content.append(new Date(System.currentTimeMillis()));
		return content.toString();
	}

	public void createContent(String id, Element parent) {
		Document dom = parent.getOwnerDocument();
		Element para = dom.createElement("p");
		para.setAttribute("id", "someDynamicContentId");
		para.appendChild(dom.createTextNode(getCurrentTimeString()));
		parent.appendChild(para);

	}

	public void dispose() {

	}

}
